<html>
<head><meta charset="utf-8"><title>parse_float · t-compiler/const-eval · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/index.html">t-compiler/const-eval</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/parse_float.html">parse_float</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="166567952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/parse_float/near/166567952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/parse_float.html#166567952">(May 26 2019 at 09:47)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> <span class="user-mention" data-user-id="119009">@eddyb</span> any idea what the purpose of this <code>parse</code> call is?<br>
<a href="https://github.com/rust-lang/rust/blob/2268d9923bcb34a6c921d285cca7fa3dba857c02/src/librustc_mir/hair/constant.rs#L89" target="_blank" title="https://github.com/rust-lang/rust/blob/2268d9923bcb34a6c921d285cca7fa3dba857c02/src/librustc_mir/hair/constant.rs#L89">https://github.com/rust-lang/rust/blob/2268d9923bcb34a6c921d285cca7fa3dba857c02/src/librustc_mir/hair/constant.rs#L89</a><br>
the result is thrown away as is the error information, but this does short-circuit in case of error. but then it parses the same thing again anyway?</p>



<a name="166568018"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/parse_float/near/166568018" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/parse_float.html#166568018">(May 26 2019 at 09:49)</a>:</h4>
<p>It parses it again with a different algorithm though. I thought it was intended to cross-validate the two implementations, but i can't explain why it combines them in this way.</p>



<a name="166570031"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/parse_float/near/166570031" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/parse_float.html#166570031">(May 26 2019 at 10:51)</a>:</h4>
<p>there used to be a comment there that referenced an issue, not sure why it got lost or what issue that was</p>



<a name="166571064"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/parse_float/near/166571064" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/parse_float.html#166571064">(May 26 2019 at 11:24)</a>:</h4>
<p>oh you're probably thinking of <a href="https://github.com/rust-lang/rust/issues/31407" target="_blank" title="https://github.com/rust-lang/rust/issues/31407">#31407</a></p>



<a name="166571757"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/parse_float/near/166571757" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/parse_float.html#166571757">(May 26 2019 at 11:47)</a>:</h4>
<p>code seems to be added by <a href="https://github.com/rust-lang/rust/commit/cf103e56bd0bfdc3ef7202ba774a1981adb36a46" target="_blank" title="https://github.com/rust-lang/rust/commit/cf103e56bd0bfdc3ef7202ba774a1981adb36a46">https://github.com/rust-lang/rust/commit/cf103e56bd0bfdc3ef7202ba774a1981adb36a46</a> (by <span class="user-mention" data-user-id="124288">@oli</span>  :D ) and I dont see a comment</p>



<a name="166722890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/parse_float/near/166722890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/parse_float.html#166722890">(May 28 2019 at 14:36)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> that's because it was copied from very old code :P</p>



<a name="166723119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/parse_float/near/166723119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/parse_float.html#166723119">(May 28 2019 at 14:39)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/e999e7b8b2e35a495d6b9630ab987c0703c6ab48/src/librustc_const_math/float.rs#L79-L89" target="_blank" title="https://github.com/rust-lang/rust/blob/e999e7b8b2e35a495d6b9630ab987c0703c6ab48/src/librustc_const_math/float.rs#L79-L89">https://github.com/rust-lang/rust/blob/e999e7b8b2e35a495d6b9630ab987c0703c6ab48/src/librustc_const_math/float.rs#L79-L89</a></p>



<a name="166723135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/parse_float/near/166723135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/parse_float.html#166723135">(May 28 2019 at 14:39)</a>:</h4>
<p>huh this is missing a FIXME</p>



<a name="166723420"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/parse_float/near/166723420" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/parse_float.html#166723420">(May 28 2019 at 14:42)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> do you remember why you removed the check that <code>libcore</code> and <code>rustc_apfloat</code> agree?</p>



<a name="166724560"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/parse_float/near/166724560" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/parse_float.html#166724560">(May 28 2019 at 14:55)</a>:</h4>
<p>yeah with such a check I wouldn't have asked</p>



<a name="166724578"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/parse_float/near/166724578" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/parse_float.html#166724578">(May 28 2019 at 14:55)</a>:</h4>
<p>but maybe they actually disagree in practice and this made more programs go through -- as in, <a href="https://github.com/rust-lang/rust/issues/31407" target="_blank" title="https://github.com/rust-lang/rust/issues/31407">https://github.com/rust-lang/rust/issues/31407</a></p>



<a name="166724645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/parse_float/near/166724645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/parse_float.html#166724645">(May 28 2019 at 14:56)</a>:</h4>
<p>if they disagree then we have an issue? but I'd defer to <span class="user-mention" data-user-id="124289">@rkruppe</span></p>



<a name="166725636"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/parse_float/near/166725636" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/parse_float.html#166725636">(May 28 2019 at 15:06)</a>:</h4>
<p>We'd have a novel (frightening) issue if they both parsed the same string as a different float. We already know they can disagree in that libcore fails to parse something apfloat can parse.</p>



<a name="166725689"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/parse_float/near/166725689" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/parse_float.html#166725689">(May 28 2019 at 15:07)</a>:</h4>
<p>oh so they disagree in which floats they accept, but if they both accept they should give the same result?</p>



<a name="166725729"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/parse_float/near/166725729" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/parse_float.html#166725729">(May 28 2019 at 15:07)</a>:</h4>
<p>Yes. The disagreement about which floats are accepted is a bug (in libcore), but a relatively benign one.</p>



<a name="166725736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/parse_float/near/166725736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/parse_float.html#166725736">(May 28 2019 at 15:07)</a>:</h4>
<p>also why do we care if the one in libcore accepts this float at all?^^ is that just serving as "extended testsuite"?</p>



<a name="166725815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/parse_float/near/166725815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/parse_float.html#166725815">(May 28 2019 at 15:08)</a>:</h4>
<p><span class="user-mention" data-user-id="124289">@rkruppe</span> we re-introduced the check that both succeed, are you saying we should also be checking that they both produce the same result in case of success?</p>



<a name="166725887"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/parse_float/near/166725887" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/parse_float.html#166725887">(May 28 2019 at 15:09)</a>:</h4>
<p>If you want better cross-validation, yeah. Accepting the right decimal strings is relatively easy compared to computing the right binary float result.</p>



<a name="166725924"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/parse_float/near/166725924" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/parse_float.html#166725924">(May 28 2019 at 15:09)</a>:</h4>
<p>we should then run a <code>check</code> crater run w/ the check reintroduced</p>



<a name="166726111"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/parse_float/near/166726111" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/parse_float.html#166726111">(May 28 2019 at 15:11)</a>:</h4>
<p>I guess? I don't think it's terribly likely that this finds any issues (I have relatively high confidence in both implementations now that they're been around long enough and have been cross-validated for a while), but if we're going to compare them <em>at all</em> then comparing the results as well seems more sensible.</p>



<a name="166726716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/parse_float/near/166726716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/parse_float.html#166726716">(May 28 2019 at 15:18)</a>:</h4>
<p>also if that line there is really just to test the libcore parser, there should be a comment saying so :)</p>



<a name="166727182"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/parse_float/near/166727182" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/parse_float.html#166727182">(May 28 2019 at 15:24)</a>:</h4>
<p>Not so much testing one implementation as sanity-checking both, but yeah, the intent should be documented so we don't need another thread like this :)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>